import os


class Log:
	logFile = None
	logFileName = ""

	def __init__(self, fileName):
		self.bind(fileName)

	def print(self, content, *contents):
		if not os.path.exists(self.logFileName):
			self.logFile = open(self.logFileName, "w")
		else:
			self.logFile = open(self.logFileName, "a+")

		if contents is None:
			print(content)
			if self.logFile is not None:
				if self.logFile.writable():
					self.logFile.write(str(content) + "\n")
		else:
			print(content, end="")
			if self.logFile is not None:
				if self.logFile.writable():
					self.logFile.write(str(content))
			for cnt in contents:
				print(cnt, end="")
				if self.logFile is not None:
					if self.logFile.writable():
						self.logFile.write(str(cnt))
			print()
			if self.logFile is not None:
				if self.logFile.writable():
					self.logFile.write("\n")

		self.close()

	def bind(self, fileName):
		self.logFileName = fileName

	def close(self):
		self.logFile.close()


log = Log("")